/*
MeeDocs - A Google Docs / Google Drive client for N9
Copyright 2012 Marcel D. Juhnke <marcel.juhnke@ovi.com>

This file is part of MeeDocs.

    MeeDocs is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 2 of the License, or
    (at your option) any later version.

    MeeDocs is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with MeeDocs.  If not, see <http://www.gnu.org/licenses/>.
*/

import QtQuick 1.1
import com.nokia.meego 1.0
import "meedocs.js" as Meedocs
import "storage.js" as Storage

Page {
    tools: commonTools

    onStatusChanged: {
        if (mainPage.status === PageStatus.Activating) {
            if (Storage.getKeyValue("accessToken")) {
                loginButton.visible = false;
                loginLabel.visible = true;
                logoutButton.visible = true;
                appWindow.pageStack.replace(Qt.resolvedUrl("HomeView.qml"));
            }
        }
    }

    PageHeader {
        id: pageHeader
        text: "Welcome to MeeDocs"
        anchors.top: parent.top
    }

    Label {
        id: loginHeading
        anchors {
            horizontalCenter: parent.horizontalCenter
            top: pageHeader.bottom
            topMargin: 64
        }
        text: "Login with your Google Docs Account.\n (You need an internet connection)"
    }

    Button {
        id: loginButton
        anchors {
            horizontalCenter: parent.horizontalCenter
            top: loginHeading.bottom
            topMargin: 64
        }
        text: qsTr("Please login")
        onClicked: appWindow.pageStack.replace(loginDialog)
    }

    Label {
        id: loginLabel
        anchors.verticalCenter: parent.verticalCenter
        anchors.horizontalCenter: parent.horizontalCenter
        text: "Authenticating, please wait!"
        visible: false
    }
}
